package com.yangtu.nearbyshop.admin.web;

import com.yangtu.nearbyshop.admin.annotation.RequiresPermissionsDesc;
import com.yangtu.nearbyshop.admin.service.AdminOrderService;
import com.yangtu.nearbyshop.core.validator.Order;
import com.yangtu.nearbyshop.core.validator.Sort;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

@RestController
@RequestMapping("/admin/dispatch")
@Validated
public class AdminGoodsOrderController {
    private final Log logger = LogFactory.getLog(AdminGoodsOrderController.class);

    @Autowired
    private AdminOrderService adminOrderService;

    /**
     * 查询订单
     *
     * @param mercNo
     * @param goodId
     * @param startTm
     * @param endTm
     * @param page
     * @param limit
     * @return
     */
    @RequiresPermissions("admin:dispatch:list")
    @RequiresPermissionsDesc(menu = {"采购配送", "采购清单"}, button = "查询")
    @GetMapping("/list")
    public Object list(String mercNo, String goodId, String ordState,
                       String startTm, String endTm,
                       @RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer limit) {
        return adminOrderService.goodsOrderbyGoodsList(mercNo, goodId, ordState, startTm, endTm, page, limit);
    }

    /**
     * 查询订单
     *
     * @param mercNo
     * @param goodId
     * @param startTm
     * @param endTm
     * @param page
     * @param limit
     * @return
     */
    @RequiresPermissions("admin:dispatch:merclist")
    @RequiresPermissionsDesc(menu = {"采购配送", "配送清单"}, button = "查询")
    @GetMapping("/merclist")
    public Object merclist(String mercNo, String goodId, String ordState,
                       String startTm, String endTm,
                       @RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer limit) {
        return adminOrderService.goodsOrderbyMercList(mercNo, goodId, ordState, startTm, endTm, page, limit);
    }

    /**
     * 查询订单
     *
     * @param mercNo
     * @param goodId
     * @param startTm
     * @param endTm
     * @param page
     * @param limit
     * @return
     */
    @RequiresPermissions("admin:dispatch:userlist")
    @RequiresPermissionsDesc(menu = {"采购配送", "用户提货清单"}, button = "查询")
    @GetMapping("/userlist")
    public Object userlist(String mercNo, String goodId, String ordState,
                       String startTm, String endTm,
                       @RequestParam(defaultValue = "1") Integer page,
                       @RequestParam(defaultValue = "10") Integer limit) {
        return adminOrderService.goodsOrderbyUsersList(mercNo, goodId, ordState, startTm, endTm, page, limit);
    }


}
